package com.ch.android.baselib

import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.core.Flowable
import io.reactivex.rxjava3.core.Observable
import io.reactivex.rxjava3.core.Scheduler
import io.reactivex.rxjava3.schedulers.Schedulers

/**
 * Author: conghao
 * Date: 2023/12/26 11:56
 * Description: MyExtensions
 */

/**
 * Observable不支持背压
 */
@JvmOverloads
fun<T: Any> Observable<T>.schedule(subscribeOn : Scheduler = Schedulers.io(),
                                   observeOn : Scheduler = AndroidSchedulers.mainThread()): Observable<T> {
    return subscribeOn(subscribeOn).observeOn(observeOn)
}

/**
 * Flowable支持背压
 */
@JvmOverloads
fun<T: Any> Flowable<T>.schedule(subscribeOn : Scheduler = Schedulers.io(),
                            observeOn : Scheduler = AndroidSchedulers.mainThread()): Flowable<T> {
    return subscribeOn(subscribeOn).observeOn(observeOn)
}

fun Int.jiaN() : Int {
    return this + 1 + 2 + 3 + 4 + 5
}

